package com.chenhl.bootmpdemo.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.chenhl.bootmpdemo.entity.TbEmp;
import com.chenhl.bootmpdemo.entity.TbUser;
import com.chenhl.bootmpdemo.mapper.EmpMapper;
import com.chenhl.bootmpdemo.mapper.UserMapper;
import com.chenhl.bootmpdemo.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, TbUser> implements IUserService
{

    @Autowired
    EmpMapper empMapper;

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void addGreen() {
        TbUser tbUser = new TbUser();
        tbUser.setUserName("zhangsan1");
        tbUser.setRealName("张三");
        this.baseMapper.insert(tbUser);
        int i = 1 / 0 ;
        addEmp();

    }


    @Override
//    @Transactional(rollbackFor = Exception.class)
    public void addEmp() {
        TbEmp emp = new TbEmp();
        emp.setEmpNo("e0003");
        emp.setDeptNo("003");

        empMapper.insert(emp);
//        int i = 1 / 0;
    }
}
